﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Framework.Repositories;
using Framework.UnitOfWork;

namespace Framework.Services
{
    public class ApplicationService : IDisposable
    {
        IUnitOfWork _unitOfWork;
        protected IUnitOfWork UnitOfWork
        {
            get { return _unitOfWork; }
        }
        public ApplicationService(IUnitOfWork unitOfWork)
        {
            _unitOfWork = unitOfWork;
        }


        protected IRepository<TAggregateRoot> GetRepository<TAggregateRoot>()
         where TAggregateRoot : class, IAggregateRoot, new()
        {
            return _unitOfWork.GetRepository<TAggregateRoot>();
        }

        #region IDisposable Members

        public void Dispose()
        {
            if (_unitOfWork != null)
            {
                _unitOfWork.Dispose();
            }
        }

        #endregion
    }
}
